/*
ID: guoxu1
PROG: clocks
LANG: C++
*/
#include <fstream>
#include <vector>
#include <set>
using namespace std;

#define cin fin
#define cout fout

const char* affects[] = 
{ "ABDE", "ABC", "BCEF", "ADG", "BDEFH", "CFI", "DEGH", "GHI", "EFHI" };

const int size = 16;
const int status_max_count = 262144;

bool status[ status_max_count ] = { false };

ifstream fin( "clocks.in" );
ofstream fout( "clocks.out" );

struct Clock
{
  unsigned int data;
  int trace;
  int affect;

  Clock()
  {
    data = 0;
  }

  inline void rotate( char c )
  {
    int t = (c - 'A') << 1;
    unsigned int v = data & ( 3 << t );
    data -= v;
    v = ( v + ( 1 << t ) ) & ( 3 << t );
    data += v;
  }

  inline void process( const char* affect )
  {
    while( *affect != '\0' )
    {
      rotate( *affect );
      affect++;
    }
  }
};

void traceprint( const vector<Clock>& tasks, const Clock& final )
{
  multiset<int> affects;
  const Clock* pc = &final;
  while( pc->trace != -1 )
  {
    //cout << pc->affect << " ";
    affects.insert( pc->affect );
    pc = &tasks[ pc->trace ];
  }
  bool first = true;
  for( set<int>::iterator it = affects.begin(); it != affects.end(); it++ )
  {
    if( !first ) cout << " ";
    first = false;
    cout << *it;
  }
  cout << endl;
}

int main()
{
  Clock start;
  for( int i = 0; i < 9; i++ )
  {
    int time = 0;
    cin >> time;
    time = ( time / 3 ) % 4;
    start.data |= ( time << ( i * 2 ) );
  }

  if( start.data == 0 )
  {
    return 0;
  }

  
  vector< Clock > tasks;
  start.trace = -1;
  tasks.push_back( start );
  status[ start.data ] = true;

  size_t pos = 0;

  while( pos < tasks.size() )
  {
    Clock cur = tasks[pos++];

    for( int i = 8; i >= 0; i-- )
    {
      Clock next = cur;
      next.trace = pos - 1;
      next.affect = i + 1;
      next.process( affects[i] );
      if( next.data == 0 )
      {
        traceprint( tasks, next );
        return 0;
      }
      if( !status[ next.data ] )
      {
        tasks.push_back( next );
        status[ next.data ] = true;
      }
    }

    //cout << tasks.size() << endl;
    pos++;
  }

  return 0;
  
}
